/**
 * 
 */
package com.gxa.ssm251.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * @author bilei
 * @date 2021��3��19��
 */
public class SeriUtil {

	/**
	 * ������Ŀ�����ʵ�����л�����,���洢���ļ���
	 * 
	 * @param path   Ŀ���ļ���·��
	 * @param object Ҫ�����л���Ŀ�����
	 */
	public static void objectToSeriFile(String path, Object object) {
		File file = new File(path);
		try (FileOutputStream fileOutputStream = new FileOutputStream(file);
				ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);) {
			objectOutputStream.writeObject(object);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/**
	 * ���ļ��з����л�����,��ö���
	 * 
	 * @param file Ŀ���ļ�
	 * @return �����л��Ķ���
	 */
	public static Object objectFromSeriFile(File file) {
		// ִ�з����л�

		Object object = null;
		try (FileInputStream fileInputStream = new FileInputStream(file);
				ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);) {
			object = objectInputStream.readObject();

		} catch (Exception e) {
			e.printStackTrace();
		}
		return object;

	}

}
